#pragma once
#ifndef __BINARYSORTTREE_H__
#define __BINARYSORTTREE_H__
#define ElementType void*

typedef struct BinarySortTreeNode
{
    ElementType data;
    struct BinarySortTreeNode* left;
    struct BinarySortTreeNode* right;
    struct BinarySortTreeNode* parent;
}BSTNode;

typedef struct BinarySortTree
{
    BSTNode* root;
}BSTree;

int InitBSTree(BSTree* tree);
void InsertElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
void FreeTree(BSTree* tree);
void PrevTravel(BSTree* tree, void (*func)(ElementType));
void MidTravel(BSTree* tree, void (*func)(ElementType));
void PostTravel(BSTree* tree, void (*func)(ElementType));
BSTNode* FindElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
void DeleteElement(BSTree* tree, ElementType element, int(*func)(ElementType, ElementType));
int GetLeafNum(BSTree* tree);

#endif